package nina.yiyou.entry.run

import spock.lang.Specification

class EntryArgParserTest extends Specification {

  String _args

  void setup() {
    // NOOP
  }

  def "Parse:满"() {
    given:
    _args = '--excel --entry salary workshop.xlsx arg2'

    when:
    def result = parse()

    then:
    result.fromExcel
    result.entryClass == 'salary'
    result.appArgs == ['workshop.xlsx', 'arg2']
  }

  def "Parse:空"() {
    given:
    _args = '--entry paystub'

    when:
    def result = parse()

    then:
    !result.fromExcel
    result.entryClass == 'paystub'
    result.appArgs == []
  }

  def parse() {
    return new EntryArgParser(_args.split()).parse()
  }
}
